<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Listener;

use App\Model;
use App\Model\CourseTaskDataDownload;
use App\Model\CourseTaskImageText;
use App\Model\CourseTaskLive;
use App\Model\CourseTaskMicroCourse;
use App\Model\CourseTaskPractice;
use App\Model\CourseTaskVideoSlicing;
use App\Model\CourseTaskWord;
use Hyperf\Database\Model\Relations\Relation;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;

#[Listener]
class MorphMapRelationListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            BootApplication::class,
        ];
    }

    public function process(object $event): void
    {
        Relation::morphMap([
            'task_image_text' => CourseTaskImageText::class,
            'task_micro_course' => CourseTaskMicroCourse::class,
            'task_practice' => CourseTaskPractice::class,
            'task_word' => CourseTaskWord::class,
            'task_live' => CourseTaskLive::class,
            'task_data_download' => CourseTaskDataDownload::class,
            'task_video_slicing' => CourseTaskVideoSlicing::class,
        ]);
    }
}
